﻿#include "dlgcard.h"
#include "ui_dlgcard.h"
#include <QSettings>

dlgcard::dlgcard(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::dlgcard)
{
    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint);
    this->setAutoFillBackground(true);
    this->setStyleSheet("background-color:white;");
    ui->lab_name->setFrameStyle(QFrame::NoFrame);
    ui->lab_title->setFrameStyle(QFrame::NoFrame);
    ui->lab_photo->setFrameStyle(QFrame::NoFrame);
    ui->lab_name->setFont( QFont( "Noto Sans S Chinese Regular", 15) );
    ui->lab_title->setFont( QFont( "Noto Sans S Chinese Regular", 15) );
    //zjz 20171113
    ui->lab_name->setWordWrap(true);
    ui->lab_title->setWordWrap(true);
    ui->lab_name->setAlignment(Qt::AlignHCenter);
    ui->lab_title->setAlignment(Qt::AlignHCenter);
}

dlgcard::~dlgcard()
{
    delete ui;
}

void dlgcard::setPic()
{
    QString pixmap="print_logo.jpg";
    ui->lab_photo->setPixmap(QPixmap(pixmap));
    ui->lab_photo->setScaledContents(true);
}

void dlgcard::slotShow(QString name)
{
    setPic();
    QString szCfg = QString("D:/update/tamirobotactivecfg.ini");
    QSettings CfgSet(szCfg, QSettings::IniFormat);
    CfgSet.setIniCodec("GB18030");
    QString title = CfgSet.value("print/title").toString();
    ui->lab_title->setText(title);
    qDebug() << u8"print two lines" << "title=" << title.toUtf8().data() << "name=" << name.toUtf8().data();
    name = name.replace(" ","\n");
    ui->lab_name->setText(name);
}
